﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tanmia.Core;
using FluentNHibernate.Mapping;

namespace Tanmia.NHibernate.Mapping
{
    public class UnitMap : ClassMap<Unit>
    {
        public UnitMap()
        {
            Table("Unit");

            Id(x => x.UnitID).Not.Nullable().GeneratedBy.Identity();

            Map(x => x.Name).Not.Nullable().Length(128).Unique();
            Map(x => x.Abbreviation).Not.Nullable().Length(8).Unique();
            Map(x => x.Scale).Not.Nullable();
            Map(x => x.Note).Nullable().Length(2048);

            References(x => x.Parent, "ParentID").Nullable();
        }
    }
}
